
const cloud = require('wx-server-sdk');

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
});

const db=cloud.database();

exports.main = async (event, context) => {
  const {account}=event.data;
  try{
    const userinfo=await db.collection("student").where({
      account:account,
    }).get();
    if(userinfo.data.length==1){
      const userlist=await db.collection("student").where({
        account:account
      }).field({
        health_insurance:true,
        health_insurance_reason:true,
        health_insurance_check:true
      }).get();
      return {success:true,message:userlist.data[0]}
    }else{
      return{success:false,message:"获取失败"}
    }
  }catch(error){
      console.error(error);
      return{success:false,message:"error"}
  }
};